//
//  ViewController.m
//  Color
//
//  Created by Justsoso on 16/2/19.
//  Copyright © 2016年 NIIT. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (IBAction)backTop:(id)sender
{
    [self.view endEditing:YES];
    self.redSilder.value = [self.redTextField.text intValue];
    self.greenSilder.value = [self.greenTextField.text intValue];
    self.blueSilder.value = [self.blueTextField.text intValue];
    self.colorLabel.backgroundColor = [UIColor colorWithRed:self.redSilder.value/255.0 green:self.greenSilder.value/255.0 blue:self.blueSilder.value/255.0 alpha:1];
}
- (IBAction)redSliderColor:(UISlider *)sender
{
    int value = sender.value;
    
    self.redTextField.text = [NSString stringWithFormat:@"%i",value];
    self.colorLabel.backgroundColor = [UIColor colorWithRed:value/255.0 green:[self.greenTextField.text intValue]/255.0 blue:[self.blueTextField.text intValue]/255.0 alpha:1];
}

- (IBAction)greenSliderColor:(UISlider *)sender
{
    int value = sender.value;
    
    self.greenTextField.text = [NSString stringWithFormat:@"%i",value];
    self.colorLabel.backgroundColor = [UIColor colorWithRed:[self.redTextField.text intValue]/255.0 green:value/255.0 blue:[self.blueTextField.text intValue]/255.0 alpha:1];
}

- (IBAction)blueSliderColor:(UISlider *)sender
{
    int value = sender.value;
    
    self.blueTextField.text = [NSString stringWithFormat:@"%i",value];
    self.colorLabel.backgroundColor = [UIColor colorWithRed:[self.redTextField.text intValue]/255.0 green:[self.greenTextField.text intValue]/255.0 blue:value/255.0 alpha:1];
}



@end
